
package com.welsy.authoring.business
{
	import com.adobe.cairngorm.business.ServiceLocator;
	
	import mx.controls.Alert;
	import mx.rpc.AbstractOperation;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.soap.mxml.WebService;		

	/**
	  * @author Welsy.org
	  * @version	$Revision: 1.1 $
	  */
	public class AddCourseDelegate
	{
		/**
		  * Delegate initialization for course component retrieval
		  * @param responder The event handler fo the server response
		  */
		public function AddCourseDelegate( responder : IResponder )
		{		
			this.service = ServiceLocator.getInstance().getWebService("wsCoursesList") as WebService;
			
			this.responder = responder;
		}
										
		/**
		  * Retrieve from the server the components for a given course
		  * @param id The ID of the course which owns the components
		  */
		public function getCourseComponents( courseId : String, parentCourseId : String, title : String, titleUser : String, authorId : String, mapView : String, navigationMap : String, state : String ) : void
		{	
			var o:AbstractOperation = service.getOperation("AddCourse");
			o.arguments.AddCourseRequest.CourseID = courseId;
			o.arguments.AddCourseRequest.ParentCourseId = parentCourseId;
			o.arguments.AddCourseRequest.Title = title;
			o.arguments.AddCourseRequest.TitleUser = titleUser;
			o.arguments.AddCourseRequest.AuthorID = authorId;
			o.arguments.AddCourseRequest.MapView = mapView;
			o.arguments.AddCourseRequest.NavigationMap = navigationMap;
			o.arguments.AddCourseRequest.State = state;
			
			var token:AsyncToken = service.AddCourse();
			// notify this command when the service call completes
			token.addResponder( responder );
		}	
		
		private var responder : IResponder;
		private var service : Object;
	}

}